<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="signupForm">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">渠道名称：</label>
                            <div class="col-sm-8">
                                <select id="channelid" onchange="getDistrict()" name="channelid"
                                        class="form-control" type="text">
                                    <option value="">---请选择---</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">sdk名称：</label>
                            <div class="col-sm-8">
                                <select id="sdkid" name="sdkid"
                                        class="form-control" type="text">
                                    <!-- <option value="">-&#45;&#45;请选择-&#45;&#45;</option>-->
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">渠道活跃用户：</label>
                            <div class="col-sm-8">
                                <input  onkeyup="this.value=this.value.replace(/\D/g,'')"
                                        onafterpaste="this.value=this.value.replace(/\D/g,'')" maxlength="11" id="channeldau" name="channeldau" class="form-control"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">渠道收入：</label>
                            <div class="col-sm-8">
                                <input maxlength="8" id="channelprofit" name="channelprofit" class="form-control"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">发布状态：</label>
                            <div class="col-sm-8">
                                <select id="publishstate" name="publishstate"
                                        class="form-control">
                                    <option value="0">未发布</option>
                                    <option value="1">已发布</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">创建日期：</label>
                            <div class="col-sm-8">
                                <input type="text" id="createtime" name="createtime" class="form-control"
                                       placeholder="请选择日期" readonly="readonly"
                                       required="required" aria-required="true"
                                       th:value="${createtime!= null ?createtime:''}"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript" src="/js/appjs/market/channelProfit/add.js">
</script>
<link rel="stylesheet" href="@{/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css}"
      th:href="@{/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css}">
<script th:src="@{/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js}"></script>
<script th:src="@{/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js}"></script>
<script type="text/javascript" th:inline="javascript">
    $(function () {
        $.ajax({
            type: 'get',
            url: '/market/sdk/listAllChannel',
            dataType: 'json',
            success: function (datas) {//返回list数据并循环获取
                var select = $("#channelid");
                /*select.append("<option value='" + "" + "'>"
                    + "---请选择---" + "</option>");*/
                for (var i = 0; i < datas.length; i++) {
                    select.append("<option value='" + datas[i].channelId + "'>"
                        + datas[i].channelName + "</option>");
                }
            }
        });
        /**
         * 日期选择器
         * @param
         */
        $("#createtime").datetimepicker({//选择年月日
            format: 'yyyy-mm-dd',
            language: 'zh-CN',
            weekStart: 1,
            todayBtn: 1,//显示‘今日’按钮
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            minView: 2,  //Number, String. 默认值：0, 'hour'，日期时间选择器所能够提供的最精确的时间选择视图。
            clearBtn: true,//清除按钮
            forceParse: 0
        });
    })

    function getDistrict() {
        $("#sdkid").empty();    //清空二级下拉框，否则会叠加
        // $("#sdkid").append("<option value='' selected='selected'>" + "---请选择---" + "</option>");
        /* var id = obj.id;
         var options = $("#" + id + " option:selected"); //获取选中的项
         alert(options.text()); //拿到选中项的值
         var countrycode = options.val();*/
        var channelid = $("#channelid").val();
        $.ajax({
            type: "post",
            url: '/market/sdk/SdkListByChannelid',
            dataType: 'json',
            data: {channelid: channelid},
            success: function (data) {
                var select = $("#sdkid");
                for (var i = 0; i < data.length; i++) {
                    select.append("<option value='" + data[i].sdkId + "'>"
                        + data[i].sdkName + "</option>");
                }
            }
        });
    }
</script>
</body>
</html>
